PluginBlockMenuItemDispatcher   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 16
rs 10
wmc 3

2 Functions

Rating   Name   Duplication   Size   Complexity  
A getMenuItem 0 10 2
A isAvailable 0 3 1
1
import { setBlockType } from 'prosemirror-commands';
2
import AbstractMenuItemDispatcher from './AbstractMenuItemDispatcher';
3
import { svgIcon } from '../MDI';
4
import MenuItem from '../MenuItem';
5
6
export default class PluginBlockMenuItemDispatcher extends AbstractMenuItemDispatcher {
7
    static isAvailable({ nodes }) {
8
        return !!nodes.dwplugin_block;
9
    }
10
11
    static getMenuItem({ nodes }) {
12
        if (!this.isAvailable({ nodes })) {
13
            throw new Error('Plugin block not available in schema!');
14
        }
15
        return new MenuItem({
16
            command: setBlockType(nodes.dwplugin_block),
17
            icon: svgIcon('puzzle'),
18
            label: LANG.plugins.prosemirror['label:pluginBlock'],
0 ignored issues
show
Bug introduced by
The variable LANG seems to be never declared. If this is a global, consider adding a /** global: LANG */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
19
        });
20
    }
21
}
22